<?php
//include_once("model/itemConfig.php");
//var_dump($organization->getAuthorized());
		    global $itemType;
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
				$year1= date('Y');
	$month= date('m');
	$date= date('d');

$pcodegroup=array();
foreach($allInventorys as $inventory){
	

	$pcode=$inventory['item']->product_code;
	  $size=$inventory['item']->size;
	
	if (array_key_exists($pcode, $pcodegroup)){
		if (array_key_exists($size, $pcodegroup[$pcode])){
			$pcodegroup[$pcode][$size]->number+=$inventory['number'];
			continue;
		}
		//array_push($pcodegroup['\''.$pcode.'\''],$inventory);
	}
        $pcodegroup[$pcode][$size]=$inventory;

}


$num=count($pcodegroup);
$result="";

 foreach($pcodegroup as $key => $pcode){
         	$two=isset($pcode['02']) ? $pcode['02']['number'] :'0';
			$four=isset($pcode['04']) ? $pcode['04']['number'] :'0';
			$six=isset($pcode['06']) ? $pcode['06']['number'] :'0';
			$eight=isset($pcode['08']) ? $pcode['08']['number'] :'0';
			$ten=isset($pcode['10']) ? $pcode['10']['number'] :'0';
			$twelve=isset($pcode['12']) ? $pcode['12']['number'] :'0';
			$f=isset($pcode['f']) ? $pcode['f']['number'] :'0';			
			$result.="['$key',$two,$four,$six,$eight,$ten,$twelve,$f],";
 }

 $result=substr($result,0,-1);
 echo $result;
  
  $h= 230+100*count($pcodegroup);
?>

	<script type="text/javascript" src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {packages: ['corechart']});
    </script>
    <script type="text/javascript">
      function drawVisualization() {
        // Create and populate the data table.
        var data = google.visualization.arrayToDataTable([
        	
          ['尺寸', '02', '04', '06','08','10', '12','均码'],
          <?php 
			echo  $result;
		  
          ?>
        ]);
      
        // Create and draw the visualization.
        new google.visualization.BarChart(document.getElementById('visualizationTotal')).
            draw(data,
                 {title:"菲雪洛琳库存(数量/款号/尺码)目前状况",
                  width:800, height:<?php echo $h;?>,
                  vAxis: {title: "生产款号",gridlinesaaa: {color: '#CCC'},titleTextStyle: {color: '#FF0000'}},
                  hAxis: {title: "数量"},
                  animation:{
        		  			duration: 1000,
        					easing: 'out'
      				}
             	}
            );
      }
      
      google.setOnLoadCallback(drawVisualization);
    </script>
    

    

	<div class="invertedshiftdown">
		
		<ul>
			<li><a href="?page=accounting_sell_record">销售统计</a></li>
			<li><a href="?page=accounting_transaction">物流统计</a></li>
			<li class="current"><a href="?page=accounting_inventory">库存统计</a></li>
			<li><a href="?page=accounting_report">财政报表</a></li>
 		</ul>




		<form id="myform">
			<input type="text" class="textinput" /> <input class="submit" type="submit" value="搜索" />
		</form>
	</div>
	<br style="clear: both;" />

<div id= 'content'>
	    	    <div id='visualizationTotal'></div>

    <?php
       foreach($allOrganizations as $organization){
   
    ?>
	<h2><?php echo $organization->name ?> 信息</h2>
	
	
    
        
        
        
	<dt class="W_bgcolor clearfix">
	<strong>基本信息</strong>
	</dt>
	<dd>
	<ul>
		<li>机构名字：<?php echo $organization->name;?></li>
		<li>机构类型：<?php echo $organizationType['w'];?></li>
		<li>描述：<?php echo $organization->des;?></li>
	</ul>
	</dd>
	<hr>	
	
	<hr>
		<h2><?php echo $organization->name ?>库存显示</h2>

	<table id="contentTable" border="1">
			<tbody><tr class="solid">
		<td>最后更改时间</td>
		<td>数量</td>
		<td>扫描条码</td>
		<td>生产款号</td>
		<td>设计版号</td>
		<td>类型</td>
        <td>年份</td>
		<td>季节</td>
		<td>流水号</td>
		<td>面料</td>
		<td>色彩</td>
		<td>尺寸</td>
        <td>设计师</td>
		<td>原价</td>
		<td>折率</td>
		<td>现售与否</td>
		<td>产品名</td>

		</tr>
	
	
		<?php
		//global $auth;
		//print_r($auth);
		  //  global $organizationType;
			//		print_r($organizationType);
		
		foreach($organization->getInventory() as $inv){
			
			$type=$inv['item']->type;
			$year=$inv['item']->year;
			$season=$inv['item']->season;
			$material=$inv['item']->material;
			$size=$inv['item']->size;
			$color=$inv['item']->color;
			$designer=$inv['item']->designer;
		?>
		<tr>
		<td><?php echo $inv['time_stamp']?></td>
		<td><?php echo $inv['number']?></td>
		<td><?php echo $inv['item']->scan_code ?></td>
		<td><?php echo $inv['item']->product_code ?></td>
		<td><?php echo $inv['item']->designer_code ?></td>
		<td><?php echo $itemType[$type] ?></td>
		<td><?php echo $itemYear[$year] ?></td>
		<td><?php echo $itemSeason[$season] ?></td>
		<td><?php echo $inv['item']->flow ?></td>
		<td><?php echo $itemMaterial[$material] ?></td>
		<td><?php echo $itemColor[$color] ?></td>
		<td><?php echo $itemSize[$size] ?></td>
		<td><?php echo $itemDesigner[$designer] ?></td>
		
				<td><?php echo $inv['item']->price;?></td>	
		<td><?php echo $inv['item']->ratio."%";?></td>	
		<td><?php echo ($inv['item']->active==1) ? '是' : '否';?></td>	
		
		<td><?php echo $inv['item']->name ?></td>
		</tr>

	
	<?php
	}
	
		
	?>
		</tbody></table>
		<?php
		}
		?>
		<h4>按条件搜索</h4>
		 <form action="" method="post">

        	
            <div class="element">
             <label class="form">扫描条码</label>
             <input type="text" id="scan_code" name="scan_code" class="text" maxlength="14" size="14"><div class="important">若为空，搜查结果会显示全部条形码</div>
            </div>
            

             <div style="clear:both;">
             	            <div class="element">

             <label class="form">最近更新时间</label>
 </div>
  <li>
<label>
从
</label>
<span>
	
	
	
<select name="fromYear">
	<?php
	for($i = 2009; $i <= 2020; $i++){
		if($year1==$i){
		 echo "<option value='$i' selected>$i</option>";
		}else{
		 echo "<option value='$i'>$i</option>";		
			
		}
	}
	?>
</select>
 <label for="Field103">年</label>
</span>
<span class="symbol">/</span>
<span>
<select name="fromMonth">
	<?php
	for($i = 1; $i <= 12; $i++){
		if($i<10){
	   		$i="0".$i;
		}
	 if($month==$i){
		 echo "<option value='$i' selected>$i</option>";
		}else{
		 echo "<option value='$i'>$i</option>";		
		}
	}
	?>
</select><label for="Field103-1">月</label>
</span> 
<span class="symbol">/</span>
<span>
<select name="fromDate">
	<?php
   for($i = 1; $i <= 31; $i++){
   	if($i<10){
	   		$i="0".$i;
		}
	   if($date==$i){
		 echo "<option value='$i' selected>$i</option>";
		}else{
		 echo "<option value='$i'>$i</option>";		
		}
	}
	?>
</select>
<label for="Field103-2">日</label>
</span>



</li>

  <li>
<label>
到
</label>
<span>
	

<select name="toYear">
	<?php
	for($i = 2009; $i <= 2020; $i++){
		if($year1==$i){
		 echo "<option value='$i' selected>$i</option>";
		}else{
		 echo "<option value='$i'>$i</option>";		
			
		}
	}
	?>
</select>
 <label for="Field103">年</label>
</span>
<span class="symbol">/</span>
<span>
<select name="toMonth">
	<?php
	for($i = 1; $i <= 12; $i++){
		if($i<10){
	   		$i="0".$i;
		}
	 if($month==$i){
		 echo "<option value='$i' selected>$i</option>";
		}else{
		 echo "<option value='$i'>$i</option>";		
			
		}
	}
	?>
</select><label for="Field103-1">月</label>
</span> 
<span class="symbol">/</span>
<span>
<select name="toDate">
	<?php
	for($i = 1; $i <= 31; $i++){
		if($i<10){
	   		$i="0".$i;
		}
	   if($date==$i){
	   
		 echo "<option value='$i' selected>$i</option>";
			
		}else{
		
		 echo "<option value='$i'>$i</option>";		
		}
	}
	?>
</select>
<label for="Field103-2">日</label>
</span>



</li>
   </div>
                <div style="clear:both;">

    <div class="element">
             <label class="form">最小数量</label>
             <input type="text" name="minNum" class="text" size="14"><div class="important">若为空，搜查结果会无最小数量限制</div>
            </div>
   <div style="clear:both;">

    <div class="element">
             <label class="form">最大数量</label>
             <input type="text" name="maxNum" class="text" size="14" ><div class="important">若为空，搜查结果会无最大数量限制</div>
            </div>
   <br>
   <div class="element">
<input type="submit" value="递交" />
        <div class="loading"></div>
    </div>
   </form>
<br>
<br>
<br>


   
<div class="clear"></div>
	</div>